﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>csnfs</Title>
      <Author>melody</Author>
      <Description>creates security node fill strategy</Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>csnfs</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>Department</ID>
          <ToolTip>Department</ToolTip>
          <Default>Department</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>department</ID>
          <ToolTip>department</ToolTip>
          <Default>department</Default>
          <Function>
          </Function>
        </Literal>
      </Declarations>
      <Code Language="csharp"><![CDATA[[Export(typeof(ISecurityNodeReportSubNodeFillStrategy)), SecuritySubNodeFillStrategyMetadata(typeof($Department$))]
    internal class $Department$NodeReportSubNodeFillStrategy : ISecurityNodeReportSubNodeFillStrategy
    {
        private readonly ISecurityDataModel model;

		[ImportingConstructor]
        public $Department$NodeReportSubNodeFillStrategy(ISecurityDataModel model)
        {
            this.model = model;
        }

        public void FillSubNodes(SecurityNodeReport securityNodeReport)
        {
            if (securityNodeReport.Type != typeof($Department$))
                throw new InvalidOperationException("Стратегия не соответсвует типу узла");

            securityNodeReport.Nodes.Clear();
            foreach (var $department$ in model.$Department$s.ToArray())
            {
                var childNode = new SecurityNodeReport($department$.Name, $department$);
                securityNodeReport.Nodes.Add(childNode);
            }
        }
    }]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>